#pragma once

#include "tcp_conn.h"
#include "time_wheel.h"

namespace qio {

class TimeWheelHandle : public TimeoutHandle {
 public:
  explicit TimeWheelHandle(TimeWheel *wheel,
                           const SharedTcpConn &weak) QIO_NOEXCEPT;

  void Pause() QIO_NOEXCEPT override;

  void Reset() QIO_NOEXCEPT override;

  TimeoutMs GetTimeoutMs() const QIO_NOEXCEPT override;

  std::shared_ptr<TimeoutHandle> GetSharedHandle() QIO_NOEXCEPT override {
    return std::static_pointer_cast<TimeoutHandle>(shared_from_this());
  }

  ~TimeWheelHandle() QIO_NOEXCEPT final;

 private:
  TimeWheel *wheel_;
  WeakTcpConn weak_tcp_conn_;
};

}  // namespace qio
